/* 
 * File:   Character.h
 * Author: Zeeno
 *
 * Created on 16. březen 2012, 8:54
 */

#ifndef CHARACTER_H
#define	CHARACTER_H

#include "../types.h"

namespace vertigo {

    struct Character {
        unsigned char * _value;
        
        static const size8 size[256];
        
        /**
         * size
         * 
         * Calculate number of octets of character from the first octet.
         * 
         * @param <code>vertigo::Character</code>
         * @return number of octets or <code>0</code> if first octet is invalid.
         */
        static size8 sizeOf(Character);

        /**
         * isValid
         * 
         * Check wheter the character is valid UTF-8 character.
         * The checking is processed according table below.
         *  
         * <table border=1>
         * <tr><td>Code Points</td><td>First Byte</td><td>Second Byte</td><td>Third Byte</td><td>Fourth Byte</td></tr>
         * <tr><td>U+0000..U+007F</td><td>00..7F</td><td></td><td></td><td></td></tr>
         * <tr><td>U+0080..U+07FF</td><td>C2..DF</td><td>80..BF</td><td></td><td></td></tr>
         * <tr><td>U+0800..U+0FFF</td><td>E0</td><td>A0..BF</td><td>80..BF</td><td></td></tr>
         * <tr><td>U+1000..U+CFFF</td><td>E1..EC</td><td>80..BF</td><td>80..BF</td><td></td></tr>
         * <tr><td>U+D000..U+D7FF</td><td>ED</td><td>80..9F</td><td>80..BF</td><td></td></tr>
         * <tr><td>U+E000..U+FFFF</td><td>EE..EF</td><td>80..BF</td><td>80..BF</td><td></td></tr>
         * <tr><td>U+10000..U+3FFFF</td><td>F0</td><td>90..BF</td><td>80..BF</td><td>80..BF</td></tr>
         * <tr><td>U+40000..U+FFFFF</td><td>F1..F3</td><td>80..BF</td><td>80..BF</td><td>80..BF</td></tr>
         * <tr><td>U+100000..U+10FFFF</td><td>F4</td><td>80..8F</td><td>80..BF</td><td>80..BF</td></tr>
         * </table>
         */
        static bool isValid(Character);
    };
}
#endif	/* CHARACTER_H */

